package test.demos.ireport.controller;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import test.demos.ireport.utils.ReportFactory;


@RestController
@RequestMapping(value = "/MasterData/Report")
public class MasterDataReportController {


	@ResponseBody
	@RequestMapping(value = "/test", method = RequestMethod.GET)
	public File getMaterialDataByMaterialCode(HttpServletRequest request) {
		File reportFile = null;
		try {
/*			MaterialSearchCriteriaBO searchCriteriaBO = new MaterialSearchCriteriaBO();
			searchCriteriaBO.setBandCode("1");
			searchCriteriaBO.setiSkip(0);
			searchCriteriaBO.setiTop(0);
			searchCriteriaBO.setPageNumber(0);
			searchCriteriaBO.setPageSize(0);
			List<MaterialMaster> materialDatas = materialDataService.getMaterialMastersByConditions(searchCriteriaBO);
			for (MaterialMaster data : materialDatas) {
				System.err.println("getMaterialCode=" + data.getMaterialCode() + "," + data.getMaterialDescCn() + ","
						+ data.getProductLine());
			}*/
			List<Object> dataList = new ArrayList<Object>();
//			dataList.addAll(materialDatas);
			reportFile = ReportFactory.generateReport(request, ReportFactory.MATERIAL_DATA_FABRIC_1, "test", "pdf",dataList);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return reportFile;
	}
}
